<?php
	session_start();
	require_once '../data/Banque.php';
	
	$banque = unserialize($_SESSION['banque']);
	$separator = ConfigClement::$separator_address;
	
	$nom = $_POST['name'];
	$adress = $_POST['adresse1'].$separator.$_POST['adresse2'].$separator.$_POST['adresse3'].$separator.$_POST['adresse4'];
	$phone = $_POST['phone'];
	$mail = $_POST['email'];
	$password = $_POST['mdp'];
	$password2 = "";
	if(isset($_POST['new_mdp']))
		$password2 = $_POST['new_mdp'];
	$banque->nom = $nom;
	$banque->adress = $adress;
	$banque->phone = $phone;
	$banque->mail = $mail;
	$isOK = 1;
	if($password != null && $password != "" && $password2 != null && $password2 != "")
	{
		if($password == $banque->password){
			$banque->password = $password2;
		}else{
			echo $banque->password;
			$isOK = 0;
		}
	}

 	if($isOK == 1){
 		$banque->updateBanque();
 		$_SESSION['banque'] = serialize($banque);
 		header("Location:../genericmessage.php?type=success&message=Vos changements ont été pris en compte");
 	} else {
 		header("Location:../myinfo.php?myinfo_error");
 	} 
?>